﻿using System;
using Castle.ActiveRecord;
using Castle.Components.Validator;

namespace MonorailScaffoldingTests.Models {
    [ActiveRecord]
    public class Customer : ActiveRecordBase {
        [ValidateIsUnique]
        [PrimaryKey]
        public int Id { get; set; }

        [Property]
        public String FirstName { get; set; }

        [Property]
        public String LastName { get; set; }

        [Property]
        public String Address { get; set; }

        [Property, ValidateLength(5)]
        public int ZipCode { get; set; }

        [Property]
        public String City { get; set; }

        [Property]
        public String Country { get; set; }

        public static Customer[] FindAll() {
            return (Customer[]) FindAll(typeof (Customer));
        }

        public static Customer FindById(int id) {
            return (Customer) FindByPrimaryKey(typeof (Customer), id);
        }
    }
}